# Maintainer: Alexey Pavlov <alexpux@gmail.com>

_realname=libatomic_ops
pkgbase=mingw-w64-${_realname}
pkgname="${MINGW_PACKAGE_PREFIX}-${_realname}"
pkgver=7.4.2
pkgrel=2
pkgdesc="Provides semi-portable access to hardware provided atomic memory operations (mingw-w64)"
arch=('any')
url="https://github.com/ivmai/libatomic_ops"
license=('GPL2' 'MIT')
source=(https://github.com/ivmai/libatomic_ops/archive/${_realname}-${pkgver//./_}.tar.gz)
sha256sums=('2616be0a2f70f7e3eb12f131a36e32723ed5a1928f17b886c3e7c62f7ed14339')

prepare(){
  cd ${srcdir}/${_realname}-${_realname}-${pkgver//./_}
  sed -i 's#pkgdata#doc#' doc/Makefile.am

  autoreconf -fi
}

build() {
  mkdir ${srcdir}/build-${MINGW_CHOST}
  cd ${srcdir}/build-${MINGW_CHOST}
  ../${_realname}-${_realname}-${pkgver//./_}/configure \
    --build=${MINGW_CHOST} \
    --host=${MINGW_CHOST} \
    --target=${MINGW_CHOST} \
    --prefix=${MINGW_PREFIX} \
    --disable-static
  make
}

check() {
  cd ${srcdir}/build-${MINGW_CHOST}
  PATH="${srcdir}//build-${MINGW_CHOST}/src/.libs:$PATH" make check
}

package() {
  cd ${srcdir}/build-${MINGW_CHOST}
  make DESTDIR="${pkgdir}" install
  install -D -m644 ${srcdir}/${_realname}-${_realname}-${pkgver//./_}/doc/LICENSING.txt "${pkgdir}${MINGW_PREFIX}/share/licenses/${_realname}/LICENSE"
}
